package com.example.learningnote.receivers;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.TextView;
import com.example.learningnote.services.FileDownloadService;

// 自定义广播
public class DownloadReceiver extends BroadcastReceiver {
    private final TextView statusTextView;

    public DownloadReceiver(TextView statusTextView) {
        this.statusTextView = statusTextView;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (FileDownloadService.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
            String fileUrl = intent.getStringExtra(FileDownloadService.EXTRA_FILE_URL);
            statusTextView.setText("Download Completed: " + fileUrl);
        }
    }
}